package tdd;

/**
 * @Author: tong wu
 * @Description:
 * @Version: 1.0
 **/
public abstract class Goods {

    private final String type;
    protected double quality;
    protected int sellIn;

    private static final double MAX_QUALITY = 50;
    private static final double MIN_VALUE = 0;

    /**
     *
     */
    abstract void updateStock();

    protected Goods(String type, double quality, int sellIn) {
        this.type = type;
        this.quality = quality;
        this.sellIn = sellIn;
    }


    protected boolean isExpired() {
        return sellIn < MIN_VALUE;
    }

    protected void increaseQuality() {
        if (quality < MAX_QUALITY) {
            quality = quality + 1;
        }
    }

    protected void decreaseQuality() {
        if (quality > MIN_VALUE) {
            quality = quality - 1;
        }
    }

    protected void decreaseSellIn() {
        sellIn = sellIn - 1;
    }



    public double getQuality() {
        return quality;
    }

    public int getSellIn() {
        return sellIn;
    }

}
